<?php
	require_once ("../includes/config.php");
	//Edit Pop-up"
	if ($_SERVER["REQUEST_METHOD"] == "POST")
	{
		$name = $_POST['name'];
		$client_type = $_POST['client_type'];
		$nationality = $_POST['nationality'];
		$identification_type = $_POST['identification_type'];
		$identification_number = $_POST['identification_number'];
		$publication_place = $_POST['publication_place'];
		$expiry_date = $_POST['expiry_date'];
		$mobile = $_POST['mobile'];
		$phone = $_POST['phone'];
		$email = $_POST['email'];
		$workplace = $_POST['workplace'];
		$adress = $_POST['adress'];
		$Notes = $_POST['Notes'];
		//Don't allow anyone other than adnmin and manager to edit notes.
		if ($_SESSION['r']>1)
		{
			$Notes=$_POST['oldNotes'];
		}
		$card_copy = $_POST['card_copy'];
		//////////////////////////////////////
		$update = query("UPDATE clients SET name=? , identification_type =? ,identification_number = ? ,publication_place=? ,
                     expiry_date = ? ,adress = ? , mobile = ? ,email= ? ,workplace =? ,phone=? ,Notes=? , nationality = ? ,client_type = ?  WHERE id= ?", $name, $identification_type, $identification_number, $publication_place, $expiry_date, $adress, $mobile, $email, $workplace, $phone, $Notes, $nationality, $client_type, $_POST['client_id']);
		///////////////////////////////////

		$_SESSION['success_message'] = "تم تعديل العميل بنجاح";

		redirect("customers.php");
	}

	else
		apologize("Sorry!");
?>